package com.lwp.lambda;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.awt.*;
import java.text.MessageFormat;
import java.time.LocalDateTime;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/**
 * Test
 *
 * @author lanwenping
 * @version 1.0
 * @date 2020/6/22 16:59
 */
public class Test {
    static Logger log = LoggerFactory.getLogger(Test.class);
    public static void main(String[] args) {
        System.out.println("测试一下111");
        log.info("123");
        log.info("123 {} === {}", 12, "bbb");
        log.info("123 {1} === {1}", 12, "bbb");

        System.out.println(MessageFormat.format("a:{1},b.{1}", "1", "2"));
        System.out.println(MessageFormat.format("a:{1},b.{0}", "1", "2"));

        Map map = new HashMap<>();
        map.put("1", 111);
        System.out.println(map.get("1"));
        System.out.println(map.get("111"));
        System.out.println((String) map.get("111"));

        Integer a = 8 ;
        int a1 = 8 ;
        System.out.println(new Integer(8).equals(new Integer(8)));
        // false
        System.out.println(new Integer(8) == new Integer(8));
        // false
        System.out.println(a == new Integer(8));
        System.out.println(a1 == new Integer(8));
        System.out.println(8 == new Integer(8));
        System.out.println(a.equals(new Integer(8)));
        System.out.println("-------------------");
        System.out.println(new String("8").equals(new String("8")));
        // false
        System.out.println(new String("8") == (new String("8")));
        // false
        System.out.println("8" == (new String("8")));
        String s = "8";
        System.out.println("8" == "8");
        System.out.println(s == "8");
//        s.intern();

        test();

        // 当前年份
        System.out.println(Calendar.getInstance().get(Calendar.YEAR));
        System.out.println(LocalDateTime.now().getYear());

    }

    public static void test() {
        Map map = new HashMap();
        Map map1 = new HashMap();
        Map map2 = new HashMap();

        map1.put(1, "test1");
        map1.put(2, "test2");
        map2.put(1, "map2test");

        map.putAll(map1);
        System.out.println(map);
        map.putAll(map2);
        System.out.println(map);

    }
    /**
     * 1、JAVA基础功能 String
     * String.format("Number:%06d, String:%s", 911,  "test");
     *
     * -->Number:000911, String:test
     *
     * 适用场景：类型格式化，占位符类型强匹配
     *
     *
     *
     * 2、JAVA基础功能 java.text.MessageFormat.format
     * MessageFormat.format("a:{1},b.{1}", "1", "2");
     *
     * -->a:2,b.2
     *
     * MessageFormat.format("b:{1},a.{0}", "1", "2");
     *
     * -->b:2,a.1
     *
     * 适用场景：可灵活使用变量数组
     *
     *
     *
     * 3、log4j占位符替换工具类
     * org.slf4j.helpers.MessageFormatter.format("{}", "~~1").getMessage()
     *
     * ~~1
     */
}
